home *** CD-ROM | disk | FTP | other *** search
- Path: howland.reston.ans.net!psinntp!psinntp!psinntp!psinntp!usenet
- From: grantp@usa.pipeline.com(Pete Grant)
- Newsgroups: comp.lang.c++
- Subject: Re: Many instance of a class
- Date: 26 Mar 1996 09:46:39 GMT
- Organization: Kalevi, Inc.
- Message-ID: <4j8edv$ges@news1.h1.usa.pipeline.com>
- References: <4j7b28$8d4@athena.ulaval.ca>
- NNTP-Posting-Host: 38.8.60.2
- X-PipeUser: grantp
- X-PipeHub: usa.pipeline.com
- X-PipeGCOS: (Pete Grant)
- X-Newsreader: Pipeline v3.5.0
-
- On Mar 25, 1996 23:50:51 in article <Many instance of a class>,
- 'duchen00@gel.ulaval.ca (Francois Duchene)' wrote:
-
-
- >Hi everyone
- >
- >I am currently writing an object oriented program with Visual
- >C++
- >and I have a problem with classes and variables scope :
- >
- >I have four different classes. Three of them have member functions
- >that must
- >be able to access all member variables of the fourth class (let's call
- >it
- >"range"). The problem is that I need a hundread instances of the
- >"range"
- >class.
- >
- >I want to be able to access any member variable of an instance of
- >"range"
- >from within any of the three others classes (member functions).
- >
- >How can I do this?
- >
- >Thanks for any answer.
- >
- >Francois Duchene
- >duchen00@gel.ulaval.ca
- >
- >N.B.: Please E-MAIL me since I don't read this group on a regular
- >basis.
-
- Make the fourth class a friend of the others.
-
- There are exceptions to every rule; however, generally, it
- is a possible design flaw if a class needs to give blanket
- authority to another to access its innards. The fact that
- you have three such classes raises the probability. Look
- again at your design and see if you can't deal with this
- situation another way.
-
- BTW, The number of instances is irrelevant in this case.
- A hundred instances of a class isn't many.
-
- --
- Pete Grant
- Kalevi, Inc.
- Software Engineering & development
-